package com.ruoyi.project.system.bundleapplication.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.bundleapplication.domain.BundleApplication;
import com.ruoyi.project.system.bundleapplication.service.IBundleApplicationService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 捆绑企业申请Controller
 * 
 * @author LCL
 * @date 2022-01-04
 */
@Controller
@RequestMapping("/system/bundleapplication")
public class BundleApplicationController extends BaseController
{
    private String prefix = "system/bundleapplication";

    @Autowired
    private IBundleApplicationService bundleApplicationService;

    @RequiresPermissions("system:bundleapplication:view")
    @GetMapping()
    public String bundleapplication()
    {
        return prefix + "/bundleapplication";
    }

    /**
     * 查询捆绑企业申请列表
     */
    @RequiresPermissions("system:bundleapplication:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BundleApplication bundleApplication)
    {
        startPage();
        List<BundleApplication> list = bundleApplicationService.selectBundleApplicationList(bundleApplication);
        return getDataTable(list);
    }

    /**
     * 导出捆绑企业申请列表
     */
    @RequiresPermissions("system:bundleapplication:export")
    @Log(title = "捆绑企业申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BundleApplication bundleApplication)
    {
        List<BundleApplication> list = bundleApplicationService.selectBundleApplicationList(bundleApplication);
        ExcelUtil<BundleApplication> util = new ExcelUtil<BundleApplication>(BundleApplication.class);
        return util.exportExcel(list, "bundleapplication");
    }

    /**
     * 新增捆绑企业申请
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存捆绑企业申请
     */
    @RequiresPermissions("system:bundleapplication:add")
    @Log(title = "捆绑企业申请", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BundleApplication bundleApplication)
    {
        return toAjax(bundleApplicationService.insertBundleApplication(bundleApplication));
    }

    /**
     * 修改捆绑企业申请
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        BundleApplication bundleApplication = bundleApplicationService.selectBundleApplicationById(id);
        mmap.put("bundleApplication", bundleApplication);
        return prefix + "/edit";
    }

    /**
     * 修改保存捆绑企业申请
     */
    @RequiresPermissions("system:bundleapplication:edit")
    @Log(title = "捆绑企业申请", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BundleApplication bundleApplication)
    {
        return toAjax(bundleApplicationService.updateBundleApplication(bundleApplication));
    }

    /**
     * 删除捆绑企业申请
     */
    @RequiresPermissions("system:bundleapplication:remove")
    @Log(title = "捆绑企业申请", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bundleApplicationService.deleteBundleApplicationByIds(ids));
    }
}
